<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class preport extends CI_Controller {

	public function __construct()
    {
        parent::__construct();
        $all_session = $this->session->all_userdata();

    
        if(@$all_session['login'][0]['mem_type'] != 2 && @$all_session['login'][0]['mem_type'] != 1 && $this->uri->segment(2) != 'report')
        {
        	redirect('authen');
        } 

    }


	public function index()
	{		
		$data['group'] = $this->preport_model->get_group();

		// echo '<pre>';
		// print_r($data['group']);
		
		$this->load->view('preport' ,$data);
	}

	public function report()
	{
		
		$all_session = $this->session->all_userdata();

		if($this->input->post('report') == 'other')
		{
			$other = $this->input->post('other');
		} else {
			$other = $this->input->post('report');
		}

		if(@$member[0]['mem_id'] == '')
		{
			$rvdo_from = $this->input->post('email');
		}

		if(@$all_session['login'] != '')
		{
			$rvdo_from = $all_session['login'][0]['mem_id'];
		}

		$input = array(
			'rvdo_ment' => $other,
			'rvdo_from' => $rvdo_from,
			'vdo_id' => $this->input->post('vdo_id'),
		);

		
		$this->preport_model->new_report($input);
		redirect('player/cs/'.$input['vdo_id']);
	}

	public function del_report()
	{
		$rvdo_id = $this->uri->segment(3);		
		$this->preport_model->del_report($rvdo_id);

		redirect('preport');
	}

	public function select_del_report()
	{
		
		$select_all = $this->input->post('select_all');	

		$vdo_all = $this->input->post('vdo_all');


		for($i=0;$i<count($select_all);$i++)
		{
			if($select_all[$i] != "")
			{
				$id = $select_all[$i];
				$this->preport_model->del_report($id);
			}
		}

		for($i=0;$i<count($vdo_all);$i++)
		{
			if($vdo_all[$i] != "")
			{
				$id = $vdo_all[$i];
				$this->preport_model->del_allvdo_report($id);
			}
		}

		redirect('preport');
	}

}